#include<iostream>
#define PROJ3
//#define TEST3
using namespace std;

int main()
{

#ifdef PROJ3
	cout<<"CREATE TABLE T1(A11,A12,A13,A14);\n";
	for(int i=0;i<6;i++)
		cout<<"INSERT INTO T1 VALUES("<<i<<","<<i%2<<","<<i%3<<","<<"0);\n";
	
	cout<<"CREATE TABLE T2(A21,A22);\n";
	for(int i=0;i<6;i++)
		cout<<"INSERT INTO T2 VALUES(0,1);\n";
	
	cout<<"CREATE TABLE T3(A31,A32,A33,A34);\n";
	for(int i=0;i<9;i++)
		cout<<"INSERT INTO T3 VALUES("<<i<<","<<i*2<<","<<i*3<<","<<i*4<<");\n";
	
	cout<<"CREATE TABLE T4(A41,A42,A43,A44);\n";
	for(int i=0;i<6;i++)
		cout<<"INSERT INTO T4 VALUES(0,1,2,3);\n";
	
	cout<<"CREATE TABLE T5(A51,A52,A53,A54);\n";
	for(int i=0;i<48;i++)
		cout<<"INSERT INTO T5 VALUES("<<i<<","<<i*2<<","<<i*3<<","<<i*4<<");\n";
	
	cout<<"CREATE TABLE T6(A61,A62,A63,A64);\n";
	cout<<"INSERT INTO T6 VALUES(0,1,2,3);\n";
#endif
#ifdef TEST3
	cout<<"PRINT BUFFER;\n";
	cout<<"SET JOIN DEBUG ON;\n";
	cout<<"CREATE INDEX I11 ON T1(A11);\n";
	cout<<"CREATE INDEX I51 ON T5(A51);\n";
	cout<<"SELECT * FROM T5;\n";
	cout<<"SELECT * FROM T5 WHERE A51=4;\n";
	cout<<"SELECT * FROM T5 WHERE A51>-1;\n";
	cout<<"SELECT * FROM T5 WHERE A51>24;\n";
	cout<<"SELECT A51 FROM T5 WHERE A51>24;\n";
	cout<<"SELECT * FROM T3,T1 WHERE T3.A31=T1.A11;\n";
	cout<<"SELECT * FROM T3,T1 WHERE T3.A31=T1.A11 AND T1.A12>0;\n";
	cout<<"SELECT * FROM T3,T1 WHERE T3.A31=T1.A11;\n";
	cout<<"CREATE INDEX I21 ON T2(A21);\n";
	cout<<"SELECT * FROM T2,T1 WHERE T1.A11=T2.A21;\n";
	cout<<"SELECT * FROM T1,T6 WHERE T1.A11=T6.A61;\n";
	cout<<"CREATE INDEX I61 ON T6(A61);\n";
	cout<<"SELECT * FROM T1,T6 WHERE T1.A11=T6.A61;\n";
	cout<<"SELECT SUM(A11) FROM T1;\n";
	cout<<"SELECT SUM(A11) FROM T1 WHERE A12>0;\n";
	cout<<"SELECT SUM(T3.A31) FROM T3,T4 WHERE T3.A31=T4.A41 AND T3.A32<8;\n";
	cout<<"SELECT AVG(A11) FROM T1;\n";
	cout<<"SELECT AVG(A11) FROM T1 WHERE A12>0;\n";
	cout<<"SELECT AVG(T3.A31) FROM T3,T4 WHERE T3.A31=T4.A41 AND T3.A32<8;\n";
	cout<<"SELECT MIN(A11) FROM T1;\n";
	cout<<"SELECT MIN(A11) FROM T1 WHERE A12>0;\n";
	cout<<"SELECT MIN(T3.A31) FROM T3,T4 WHERE T3.A31=T4.A41 AND T3.A32<8;\n";
	cout<<"SELECT MAX(A11) FROM T1;\n";
	cout<<"SELECT MAX(A11) FROM T1 WHERE A12>0;\n";
	cout<<"SELECT MAX(T3.A31) FROM T3,T4 WHERE T3.A31=T4.A41 AND T3.A32<8;\n";
	cout<<"SELECT COUNT(A11) FROM T1;\n";
	cout<<"SELECT COUNT(A11) FROM T1 WHERE A12>0;\n";
	cout<<"SELECT COUNT(T3.A31) FROM T3,T4 WHERE T3.A31=T4.A41 AND T3.A32<8;\n";
	cout<<"PRINT BUFFER;\n";
#endif
	
	cout<<"QUIT;\n";
	return 0;
}
